package br.com.firula.web.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.dispatcher.FilterDispatcher;

public class FirulaFilterDispatcher extends FilterDispatcher {
	
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		

        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
//        ServletContext servletContext = getServletContext();

        try {
//            request = prepareDispatcherAndWrapRequest(request, response);
//            ActionMapping mapping;
        	if (request.getRequestURI().indexOf("/tinyfck/") != -1 || request.getRequestURI().indexOf("dojo/") != -1 || request.getRequestURI().indexOf("reports/") != -1){
            	 
               // there is no action in this request, should we look for a static resource?
//                String resourcePath = RequestUtils.getServletPath(request);
//
//                if ("".equals(resourcePath) && null != request.getPathInfo()) {
//                    resourcePath = request.getPathInfo();
//                }
//
//                if (resourcePath.startsWith("/struts") ) {
//                    String name = resourcePath.substring("/struts".length());
//                    findStaticResource(name, request, response);
//                } else {
                    // this is a normal request, let it pass through
                    chain.doFilter(request, response);
//                }
                
                // The framework did its job here
                return;
            } else {
            	super.doFilter(req, res, chain);
            }

        } finally {
        }
		
	}

}
